url = 'https://www.acwing.com/problem/content/800/'

n, m, q = map(int, input().split())

a = [list(map(int, input().split())) for _ in range(n)]
b = [[0] * (m+10) for _ in range(n+10)]

def insert(x1, y1, x2, y2, c):
    b[x1][y1] += c
    b[x2+1][y1] -= c
    b[x1][y2+1] -= c
    b[x2+1][y2+1] += c

for i in range(1, n+1):
    for j in range(1, m+1):
        insert(i, j, i, j, a[i-1][j-1])

for _ in range(q):
    x1, y1, x2, y2, c = map(int, input().split())
    insert(x1, y1, x2, y2, c)

for i in range(1, n+1):
    for j in range(1, m+1):
        b[i][j] += b[i-1][j] + b[i][j-1] - b[i-1][j-1]
        print(b[i][j], end=' ')
    print()
